﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
//是否缴费判断
public partial class BM_BM4 : BasePage
{
    public string orderId;
    string emId = string.Empty;
    string emYear = string.Empty;
    string emNum = string.Empty;
    HuatICBCPayService.ICBCService payService = new HuatICBCPayService.ICBCService();
    HuatICBCPayService.ICBC payICBCModel = new HuatICBCPayService.ICBC();
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (Request.QueryString.Count > 0)
        {
            orderId = Request.Params["OrderID"].Trim();
        }
        else
        {
            Response.Redirect(BSUtility.mainUrl + "default.aspx");
        }
        //报名状态判断
        DataTable dt_apply = Exam.getApplyInfoByOrderId(orderId);
        if (dt_apply.Rows.Count > 0)
        {
            //报名状态
            string state = dt_apply.Rows[0]["ApplyState"].ToString();
            string emId = dt_apply.Rows[0]["EmID"].ToString();
            NoAccess.JumpToDefaultPageNoAccessTime(this, emId);
            if (state == "0")
            {
                Response.Redirect(BSUtility.mainUrl + "BM/ExamSelect.aspx?");
            }
            else if (state == "2")
            {
                Response.Redirect(BSUtility.mainUrl + "BM/BM5.aspx?OrderID="+orderId);
            }
        }


        if (!Page.IsPostBack)
        {
            DataTable dt = Exam.getOrderInfoByOrderID(orderId);
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                if (dr["OrderState"].ToString() == "5" || dr["OrderState"].ToString() == "0")
                {
                    DataTable dtStudInfo = Exam.getStudInfoByIdCard(dr["StudIdcard"].ToString());
                    DataRow drStudInfo = dtStudInfo.Rows[0];
                    OrderIDText.Text = dr["OrderID"].ToString();
                    NameText.Text = drStudInfo["StudName"].ToString();
                    SFZHText.Text = drStudInfo["StudIdcard"].ToString();
                    SIDText.Text = drStudInfo["StudID"].ToString();
                    ClassText.Text = drStudInfo["StudClassName"].ToString();
                    DepText.Text = drStudInfo["StudDeptName"].ToString();
                    ExamNameText.Text = dr["EmAllName"].ToString();
                    SexText.Text = drStudInfo["StudSex"].ToString();
                    TelPhoneText.Text = drStudInfo["StudTel"].ToString();

                    CostText.Text = dr["EmCost"].ToString();
                    emId = dr["EmID"].ToString();
                    DataTable dt_time = Exam.getEmTimeByEmId(emId);
                    if (dt_time.Rows.Count > 0)
                    {
                        DataRow dr_time = dt_time.Rows[0];
                        emYear = dr_time["EmYear"].ToString();
                        emNum = dr_time["EmNum"].ToString();
                    }
                    if (dt_apply.Rows.Count > 0)
                    {
                        DataRow dr_apply = dt_apply.Rows[0];
                        LevelName_Text.Text = dr_apply["EmRankName"].ToString();
                    }
                }
                else
                    Response.Redirect(BSUtility.mainUrl + "BM/ExamSelect.aspx");
                
                string cusOrderId = "CET" + emYear + emNum + "-" + orderId;
                lbGoPay.OnClientClick = "window.open('GoPay.aspx?OrderID=" + orderId + "');";
                hlPay.NavigateUrl = BSUtility.mainUrl + "Users/PayReturn.aspx?OrderID=" + cusOrderId ;
            }
                     
        }
    }



}
